<?php

/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| Simply tell Laravel the HTTP verbs and URIs it should respond to. It is a
| breeze to setup your application using Laravel's RESTful routing and it
| is perfectly suited for building large applications and simple APIs.
|
| Let's respond to a simple GET request to http://example.com/hello:
|
|		Route::get('hello', function()
|		{
|			return 'Hello World!';
|		});
|
| You can even respond to more than one URI:
|
|		Route::post(array('hello', 'world'), function()
|		{
|			return 'Hello World!';
|		});
|
| It's easy to allow URI wildcards using (:num) or (:any):
|
|		Route::put('hello/(:any)', function($name)
|		{
|			return "Welcome, $name.";
|		});
|
*/

Route::get('/', function()
{
	return View::make('home.index');
});
/*
Route::get('course', function()
{
	return View::make('home.course');
});
Route::get('video', function()
{
	return View::make('home.video');
});
Route::get('schedule', function()
{
	return View::make('home.schedule');
});
Route::get('search', function()
{
	return View::make('home.search');
});
Route::get('login', function()
{
	return View::make('home.login');
});
Route::get('register', function()
{
	return View::make('home.register');
});*/

//-------added by xiepengcheng---------
Route::controller('home.test');
Route::controller('home.index');
Route::controller('home');
Route::controller('category.deal');
Route::controller('fileupload.deal');
//Route::controller('video.item');
Route::controller('video.review');
Route::controller('video.file');
Route::controller('admin.category');
Route::controller('admin.sign');

//------------add end-------------


Route::get('admin/sign/in', function()
{
	return View::make('admin.sign.in');
});
Route::get('admin/index',array('before'=>'auth', function()
{
	return View::make('admin.index');
}));
Route::get(array('admin/file/index','/admin/content/index',
    '/admin/category/index','/admin/user/index'), array('before'=>'auth', function()
{
	return View::make('admin.common.dashboard');
}));

/*Route::get('admin/manager/index', function()
{
	return View::make('admin.manager.list');
});*/

Route::controller('admin.manager');
Route::controller('admin.news');
Route::controller('admin.review');
Route::controller('admin.video');

Route::get('login', array('as' => 'home.login', 'uses' => 'home@login'));
Route::get('reviews', array('as' => 'home.reviews', 'uses' => 'home@reviews'));
Route::get('logout', array('as' => 'home.logout', 'uses' => 'home@logout'));
Route::post('login', array('as' => 'home.login', 'uses' => 'home@login'));
Route::get('register', array('as' => 'home.register', 'uses' => 'home@register'));
Route::post('register', array('as' => 'home.register', 'uses' => 'home@register'));
Route::get('course', array('as' => 'home.course', 'uses' => 'home@course'));
Route::get('search', array('as' => 'home.search', 'uses' => 'home@search'));
Route::get('video', array('as' => 'home.video', 'uses' => 'home@video'));
Route::get('schedule', array('as' => 'home.schedule', 'uses' => 'home@schedule'));


Route::get('admin/umams/about', function()
{
	return View::make('admin.umams.about');
});
Route::get('admin/umams/guide/(:num?)', function($step = 1)
{
	return View::make('admin.umams.guide')->with('step',$step);
});

/*
|--------------------------------------------------------------------------
| Application 404 & 500 Error Handlers
|--------------------------------------------------------------------------
|
| To centralize and simplify 404 handling, Laravel uses an awesome event
| system to retrieve the response. Feel free to modify this function to
| your tastes and the needs of your application.
|
| Similarly, we use an event to handle the display of 500 level errors
| within the application. These errors are fired when there is an
| uncaught exception thrown in the application.
|
*/

Event::listen('404', function()
{
	return Response::error('404');
});

Event::listen('500', function()
{
	return Response::error('500');
});

/*
|--------------------------------------------------------------------------
| Route Filters
|--------------------------------------------------------------------------
|
| Filters provide a convenient method for attaching functionality to your
| routes. The built-in before and after filters are called before and
| after every request to your application, and you may even create
| other filters that can be attached to individual routes.
|
| Let's walk through an example...
|
| First, define a filter:
|
|		Route::filter('filter', function()
|		{
|			return 'Filtered!';
|		});
|
| Next, attach the filter to a route:
|
|		Route::get('/', array('before' => 'filter', function()
|		{
|			return 'Hello World!';
|		}));
|
*/

Route::filter('before', function()
{
    // Do stuff before every request to your application...
});

Route::filter('after', function($response)
{
// Do stuff after every request to your application...
});

Route::filter('csrf', function()
{
	if (Request::forged()) return Response::error('500');
});

Route::filter('auth', function()
{
	if (!Auth::check()) return Redirect::to('admin/sign/in');
});

Route::filter('admin_asset',function(){
    Admin_Asset::invoke();
});

Laravel\Routing\Route::filter('pattern: admin/*', 'admin_asset');
Laravel\Routing\Route::filter('pattern: admin/index', 'auth');
Laravel\Routing\Route::filter('pattern: admin/category/*', 'auth');
Laravel\Routing\Route::filter('pattern: admin/fileupload/*', 'auth');
Laravel\Routing\Route::filter('pattern: admin/video/*', 'auth');
Laravel\Routing\Route::filter('pattern: admin/manager/*', 'auth');
Laravel\Routing\Route::filter('pattern: admin/news/*', 'auth');
Laravel\Routing\Route::filter('pattern: admin/review/*', 'auth');

Route::filter('home_asset',function(){
    Home_Asset::invoke();
});

Laravel\Routing\Route::filter('pattern: *', 'home_asset');
